<?php
/**
 * @author wyl
 * @date 2015-12-16 09:13:58
 * @param  $args:0  脚本开始时间  1 用户ID  2 auctionId
 */
Yii::import('dao.bidAuction.BidAuction');
Yii::import('dao.CustomerInfoDao');
Yii::import('application.components.Log');
class PresureWorkerCommand extends CConsoleCommand{
    public $endTime;
    public $customerId;
    public $auctionId;
    public $_log;
    
    public function init(){
       $this->_log=new Log();  
       $this->_log->addDir('pressure')->setFile('pressure');
    }
    
	public function run($args){
	   $this->endTime=$args[0];
	   $this->customerId=$args[1];
	   $this->auctionId=$args[2];
	   while (true){
           echo 'wait_'.$this->customerId;
	       if (time()>=$this->endTime){
	           echo $this->customerId.'_LOOP_END';
	           break;
	       }
	   }
	   /**
	    * 执行bid操作的代码写在下面
	    */
	   $bidAuction=new BidAuction();
	   $bidAuction->customerId=$this->customerId;
	   $bidAuction->auctionId=$this->auctionId;
	   $result=$bidAuction->bid();
	   $this->_log->addLog($result,'PRESURE_AUCTION_RESULT'.$this->auctionId.'_'.time());
  	}
}